{smcl}
{txt}{sf}{ul off}{.-}
      name:  {res}<unnamed>
       {txt}log:  {res}/Users/fcoell/Dropbox/PATSTAT/DATA/../logs/Appendix_Fig9_Table10.smcl
  {txt}log type:  {res}smcl
 {txt}opened on:  {res}22 Jun 2020, 10:18:15
{txt}
{com}. di "******************** Appendix Figure 9 and Table 10 **********************"
{res}******************** Appendix Figure 9 and Table 10 **********************
{txt}
{com}. 
. use finalsample, clear
{txt}
{com}. contract hrm
{txt}
{com}. save $tmp/tmpfinal, replace
{txt}file /tmp/tmpfinal.dta saved

{com}. 
. use weightswic5, clear
{txt}
{com}. keep hrm appln headq w
{txt}
{com}. ren w w1985
{res}{txt}
{com}. merge 1:1 appln hrm using weightswic5_85to95
{res}
{txt}{col 5}Result{col 38}# of obs.
{col 5}{hline 41}
{col 5}not matched{col 30}{res}       4,085,581
{txt}{col 9}from master{col 30}{res}       2,346,831{txt}  (_merge==1)
{col 9}from using{col 30}{res}       1,738,750{txt}  (_merge==2)

{col 5}matched{col 30}{res}         503,311{txt}  (_merge==3)
{col 5}{hline 41}

{com}. ren w w1995
{res}{txt}
{com}. keep hrm appln headq w1985 w1995
{txt}
{com}. merge 1:1 appln hrm using weightswic5_95to05
{res}
{txt}{col 5}Result{col 38}# of obs.
{col 5}{hline 41}
{col 5}not matched{col 30}{res}       7,488,107
{txt}{col 9}from master{col 30}{res}       4,111,525{txt}  (_merge==1)
{col 9}from using{col 30}{res}       3,376,582{txt}  (_merge==2)

{col 5}matched{col 30}{res}         477,367{txt}  (_merge==3)
{col 5}{hline 41}

{com}. ren w w2005
{res}{txt}
{com}. keep hrm appln headq w1985 w1995 w2005
{txt}
{com}. merge m:1 hrm using $tmp/tmpfinal, keep(match)
{res}
{txt}{col 5}Result{col 38}# of obs.
{col 5}{hline 41}
{col 5}not matched{col 30}{res}               0
{txt}{col 5}matched{col 30}{res}         261,523{txt}  (_merge==3)
{col 5}{hline 41}

{com}. drop _merge _freq
{txt}
{com}. foreach v of varlist w???? {c -(}
{txt}  2{com}.   replace `v'=0 if `v'==. 
{txt}  3{com}. {c )-}
{txt}(126,976 real changes made)
(152,603 real changes made)
(102,267 real changes made)

{com}. 
. label var w1985 "Weight, 1985"
{txt}
{com}. label var w1995 "Weight, 1995"
{txt}
{com}. label var w2005 "Weight, 2005"
{txt}
{com}. 
. gen D1985 = w1985>0
{txt}
{com}. gen D1995 = w1995>0
{txt}
{com}. gen D2005 = w2005>0
{txt}
{com}. egen mkts85 = sum(D1985), by(hrm)
{txt}
{com}. gen same1=D1985==1 & D1995==1
{txt}
{com}. gen same2=D1985==1 & D2005==1
{txt}
{com}. save $tmp/tmp, replace
{txt}file /tmp/tmp.dta saved

{com}. 
. * Intensive margin
. 
. use $tmp/tmp, clear 
{txt}
{com}. lpoly w1995 w1985 if same1, noscatter ci kernel(epan2) nograph gen(xfit1 y1) se(se1)
{res}{txt}
{com}. lpoly w2005 w1985 if same2 , noscatter ci kernel(epan2) nograph gen(xfit2 y2) se(se2)
{res}{txt}
{com}. capture drop lb? ub?
{txt}
{com}. gen lb1 = y1 - invnormal(.975)*se1
{txt}(261,473 missing values generated)

{com}. gen ub1 = y1 + invnormal(.975)*se1
{txt}(261,473 missing values generated)

{com}. gen lb2 = y2 - invnormal(.975)*se2
{txt}(261,473 missing values generated)

{com}. gen ub2 = y2 + invnormal(.975)*se2
{txt}(261,473 missing values generated)

{com}. sort xfit1
{txt}
{com}. twoway rarea lb1 ub1 xfit1  || rarea lb2 ub2 xfit2 || ///
>        line y1 xfit1 || line y2 xfit2 , scheme(lean1) xtitle("1985 weights") ytitle("Future weights") ///
>            legend(on order(3 4) pos(5) ring(0) label(1 "") label(3 "1995") label(4 "2005"))
{res}{txt}
{com}. graph export "../graph/persistence_weights.eps", as(eps) preview(on) replace
{txt}(file ../graph/persistence_weights.eps written in EPS format)

{com}. graph save "../graph/persistence_weights.gph", replace
{res}{txt}(file ../graph/persistence_weights.gph saved)

{com}. 
. reg w1995 w1985 if same1

{txt}      Source {c |}       SS           df       MS      Number of obs   ={res}    58,572
{txt}{hline 13}{c +}{hline 34}   F(1, 58570)     > {res} 99999.00
{txt}       Model {c |} {res} 6728.75692         1  6728.75692   {txt}Prob > F        ={res}    0.0000
{txt}    Residual {c |} {res} 2955.19729    58,570  .050455818   {txt}R-squared       ={res}    0.6948
{txt}{hline 13}{c +}{hline 34}   Adj R-squared   ={res}    0.6948
{txt}       Total {c |} {res} 9683.95421    58,571  .165337013   {txt}Root MSE        =   {res} .22462

{txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12}
{col 1}       w1995{col 14}{c |}      Coef.{col 26}   Std. Err.{col 38}      t{col 46}   P>|t|{col 54}     [95% Con{col 67}f. Interval]
{hline 13}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12}
{space 7}w1985 {c |}{col 14}{res}{space 2} .8272947{col 26}{space 2} .0022654{col 37}{space 1}  365.18{col 46}{space 3}0.000{col 54}{space 4} .8228544{col 67}{space 3} .8317349
{txt}{space 7}_cons {c |}{col 14}{res}{space 2} .0764438{col 26}{space 2} .0015791{col 37}{space 1}   48.41{col 46}{space 3}0.000{col 54}{space 4} .0733489{col 67}{space 3} .0795388
{txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12}
{res}{txt}
{com}. reg w2005 w1985 if same2

{txt}      Source {c |}       SS           df       MS      Number of obs   ={res}    58,889
{txt}{hline 13}{c +}{hline 34}   F(1, 58887)     = {res} 72694.09
{txt}       Model {c |} {res} 4996.70231         1  4996.70231   {txt}Prob > F        ={res}    0.0000
{txt}    Residual {c |} {res} 4047.65774    58,887  .068736015   {txt}R-squared       ={res}    0.5525
{txt}{hline 13}{c +}{hline 34}   Adj R-squared   ={res}    0.5525
{txt}       Total {c |} {res} 9044.36005    58,888  .153585791   {txt}Root MSE        =   {res} .26218

{txt}{hline 13}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12}
{col 1}       w2005{col 14}{c |}      Coef.{col 26}   Std. Err.{col 38}      t{col 46}   P>|t|{col 54}     [95% Con{col 67}f. Interval]
{hline 13}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12}
{space 7}w1985 {c |}{col 14}{res}{space 2} .7237039{col 26}{space 2} .0026842{col 37}{space 1}  269.62{col 46}{space 3}0.000{col 54}{space 4} .7184429{col 67}{space 3} .7289649
{txt}{space 7}_cons {c |}{col 14}{res}{space 2} .1018279{col 26}{space 2} .0020058{col 37}{space 1}   50.77{col 46}{space 3}0.000{col 54}{space 4} .0978966{col 67}{space 3} .1057592
{txt}{hline 13}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12}
{res}{txt}
{com}. pwcorr w1995 w1985 if same1, sig

             {txt}{c |}    w1995    w1985
{hline 13}{c +}{hline 18}
       w1995 {c |} {res}  1.0000 
             {txt}{c |}
             {c |}
       w1985 {c |} {res}  0.8336   1.0000 
             {txt}{c |}{res}   0.0000
             {txt}{c |}

{com}. pwcorr w2005 w1985 if same2, sig

             {txt}{c |}    w2005    w1985
{hline 13}{c +}{hline 18}
       w2005 {c |} {res}  1.0000 
             {txt}{c |}
             {c |}
       w1985 {c |} {res}  0.7433   1.0000 
             {txt}{c |}{res}   0.0000
             {txt}{c |}

{com}. 
. * Aggreate exit rate
. use $tmp/tmp, clear
{txt}
{com}. collapse (mean) D1985 D1995 D2005 (semean) se85=D1985 se95=D1995 se05=D2005 if D1985==1
{txt}
{com}. list
{txt}
     {c TLC}{hline 7}{c -}{hline 10}{c -}{hline 10}{c -}{hline 6}{c -}{hline 10}{c -}{hline 10}{c TRC}
     {c |} {res}D1985      D1995      D2005   se85       se95       se05 {txt}{c |}
     {c LT}{hline 7}{c -}{hline 10}{c -}{hline 10}{c -}{hline 6}{c -}{hline 10}{c -}{hline 10}{c RT}
  1. {c |} {res}    1   .4353274   .4376835      0   .0013517   .0013525 {txt}{c |}
     {c BLC}{hline 7}{c -}{hline 10}{c -}{hline 10}{c -}{hline 6}{c -}{hline 10}{c -}{hline 10}{c BRC}

{com}. 
. * Aggregate entry rate
. use /tmp/tmp, clear
{txt}
{com}. collapse (mean) D1985 D1995 D2005 (semean) se85=D1985 se95=D1995 se05=D2005 if D2005==1
{txt}
{com}. list
{txt}
     {c TLC}{hline 10}{c -}{hline 10}{c -}{hline 7}{c -}{hline 10}{c -}{hline 10}{c -}{hline 6}{c TRC}
     {c |} {res}   D1985      D1995   D2005       se85       se95   se05 {txt}{c |}
     {c LT}{hline 10}{c -}{hline 10}{c -}{hline 7}{c -}{hline 10}{c -}{hline 10}{c -}{hline 6}{c RT}
  1. {c |} {res}.3697757   .3899005       1   .0012097   .0012222      0 {txt}{c |}
     {c BLC}{hline 10}{c -}{hline 10}{c -}{hline 7}{c -}{hline 10}{c -}{hline 10}{c -}{hline 6}{c BRC}

{com}. 
. * What is the overall probability of patenting in a market (1985) ? 
. use /tmp/tmp, clear
{txt}
{com}. collapse (count) D???? if D1985==1, by(hrm)
{txt}
{com}. count // 72188 firms
  {res}72,188
{txt}
{com}. use /tmp/tmp, clear
{txt}
{com}. collapse (count) D???? if D1985==1, by(appln)
{txt}
{com}. count // 51 destinations
  {res}51
{txt}
{com}. use /tmp/tmp, clear
{txt}
{com}. count if D1985==1 // 134547 firm-destinations
  {res}134,547
{txt}
{com}. * Unconditional probability is 3.65%
. 
. use /tmp/tmp, clear
{txt}
{com}. collapse (count) D???? if D1995==1, by(hrm)
{txt}
{com}. count // 41280 firms
  {res}41,280
{txt}
{com}. use /tmp/tmp, clear
{txt}
{com}. collapse (count) D???? if D1995==1, by(appln)
{txt}
{com}. count // 80 destinations
  {res}80
{txt}
{com}. use /tmp/tmp, clear
{txt}
{com}. count if D1995==1 // 108920 firm-destinations
  {res}108,920
{txt}
{com}. * Unconditional probability is 3.30%
. 
. use /tmp/tmp, clear
{txt}
{com}. collapse (count) D???? if D2005==1, by(hrm)
{txt}
{com}. count // 51710 firms
  {res}51,710
{txt}
{com}. use /tmp/tmp, clear
{txt}
{com}. collapse (count) D???? if D2005==1, by(appln)
{txt}
{com}. count // 89 destinations
  {res}89
{txt}
{com}. use /tmp/tmp, clear
{txt}
{com}. count if D2005==1 // 159256 firm-destinations
  {res}159,256
{txt}
{com}. * Unconditional probability is 3.46%
. 
. log close
      {txt}name:  {res}<unnamed>
       {txt}log:  {res}/Users/fcoell/Dropbox/PATSTAT/DATA/../logs/Appendix_Fig9_Table10.smcl
  {txt}log type:  {res}smcl
 {txt}closed on:  {res}22 Jun 2020, 10:18:47
{txt}{.-}
{smcl}
{txt}{sf}{ul off}